package com.congco.twodatasourcedemo.service.impl;

import com.congco.twodatasourcedemo.entity.School;
import com.congco.twodatasourcedemo.entity.User;
import com.congco.twodatasourcedemo.mapper.first.UserMapper;
import com.congco.twodatasourcedemo.mapper.second.SchoolMapper;
import com.congco.twodatasourcedemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private SchoolMapper schoolMapper;

    @Override
    public User getUser(Long id){
        User user =this.userMapper.findById(id);
        School school =this.schoolMapper.findByName("STAND");
        user.setSchool(school);
        return user;
    }
}
